import java.util.Locale;

public class Practice {
    public static void main(String[] args) {
        String s = "cat";
        String s1 = "DOG";
        System.out.println(s1.toLowerCase());
        System.out.println(s.toUpperCase());
    }
    public static void main11(String[] args) {
        String s = String.valueOf(123);

        System.out.println(s);
    }
    public static void main10(String[] args) {
        String s1 = "123";
        int a = Integer.parseInt(s1);
        float a2 = Float.parseFloat(s1);
        System.out.println(a2);
        System.out.println(a);

    }
    public static void main9(String[] args) {
        String s = "handsome";
        System.out.println(s.lastIndexOf('d',6));
    }
    public static void main8(String[] args) {
        String s = "helloWorld";
        System.out.println(s.indexOf('l',5));
        //System.out.println(s.indexOf('l'));
    }
    public static void main7(String[] args) {
        String s = "helloWorld";
        //System.out.println(s.charAt(4));
        //System.out.println(s.indexOf('l'));
        //遍历s中的每一个元素
        for (int i = 0; i < s.length(); i++) {
            System.out.print(s.charAt(i)+" ");
        }
    }
    public static void main6(String[] args) {
        String s1 = "cater";
        String s2 = "cat";
        System.out.println(s1.compareTo(s2));
    }
    public static void main5(String[] args) {
        String s1 = "CATER";
        String s2 = "cater";
        //compareToIgnoreCase()是忽略字母大小写，进行比较
        System.out.println(s1.compareToIgnoreCase(s2));
    }
    public static void main4(String[] args) {
        String s1 = "cancel";
        String s2 = "cat";
        //compareTo比较两个字符串大小时，若s1>s2,返回正数；s1<s2,返回负数；s1与s2相等，返回0
        System.out.println(s1.compareTo(s2));
    }

    public static void main3(String[] args) {
        String s = "cat";
        String s0 = "cat";
        System.out.println(s == s0);//比较内容（值）
        String s1 = new String("cat");
        String s2 = new String("cat");
        System.out.println(s1.equals(s2));//比较两个引用不同对象内容一样
        System.out.println(s1==s2);//比较两个引用变量引用的是否为同一址
    }
    public static void main2(String[] args) {
        String s1 = "";
        String s2 = "dog";
        String s3 = null;//s3这个引用不指向任何对象

        System.out.println(s1.length());//判断字符串长度
        System.out.println(s1.isEmpty());//判断字符串是否为空
        System.out.println(s2.isEmpty());
    }
    public static void main1(String[] args) {
        String s1 = "helloWorld";
        System.out.print(s1+" ");
        System.out.println(s1.length());//获取字符串长度

        String s2 = new String("cat");
        System.out.println(s2);
        char[] ch = {'h','e','l','l','o'};
        System.out.println(ch.length);
        String s3 = new String(ch);//将字符数组构造成字符串
        System.out.println(s3);
    }
}
